#ifndef WXWIDGETSGUI_H
#define WXWIDGETSGUI_H

#include "../wxsgui.h"
#include "../wxscodinglang.h"


class wxWidgetsGUI : public wxsGUI {
    DECLARE_CLASS( wxWidgetsGUI )
  public:

    wxWidgetsGUI( wxsProject* Project );


    virtual ~wxWidgetsGUI();


    inline wxsCodingLang GetLanguage() { return m_AppLanguage; }


    inline void SetLanguage( wxsCodingLang Language ) { m_AppLanguage = Language; }


    inline const wxString& GetAppSourceFile() { return m_AppFile; }


    void SetAppSourceFile( const wxString& NewAppFile );


    inline wxArrayString& GetLoadedResources() { return m_LoadedResources; }


    inline const wxString& GetMainResourceName() { return m_MainResource; }


    inline void SetMainResourceName( const wxString& Resource ) { m_MainResource = Resource; }


    inline void GetInitParams( bool& CallInitAll, bool& CallInitAllNecessary ) { CallInitAll = m_CallInitAll; CallInitAllNecessary = m_CallInitAllNecessary; }


    inline void SetInitParams( bool CallInitAll = true, bool CallInitAllNecessary = true ) { m_CallInitAll = CallInitAll; m_CallInitAllNecessary = CallInitAllNecessary; }

  private:

    virtual cbConfigurationPanel* OnBuildConfigurationPanel( wxWindow* Parent );
    virtual void OnRebuildApplicationCode();
    virtual bool OnCheckIfApplicationManaged();
    virtual bool OnCreateApplicationBinding();
    virtual void OnReadConfig( TiXmlElement* element );
    virtual void OnWriteConfig( TiXmlElement* element );


    bool IsAppSourceManaged( const wxString& FileName, wxsCodingLang Lang );


    bool ScanForApp( ProjectFile* File );


    bool AddSmithToApp( const wxString& RelativeFileName, wxsCodingLang Lang );


    bool CreateNewApp( const wxString& FileName );


    wxString GetAppClassName( const wxString& Source, wxsCodingLang Lang );


    void EnumerateMainResources( wxArrayString& Names );


    static inline bool IsWhite( wxChar Ch );
    static inline bool IsWhite( const wxString& Str, int Pos );
    static inline bool Match( const wxString& Str, int Pos, wxChar Ch );

    wxString m_AppFile;               ///< \brief Source file defining application
    wxArrayString m_LoadedResources;  ///< \brief List of automatically loaded resource files
    wxString m_MainResource;          ///< \brief Resource used by default
    bool m_CallInitAll;               ///< \brief True if wxXmlResource::Get()->InitAllHandlers() should be called while initialization
    bool m_CallInitAllNecessary;      ///< \brief True if should call wxXmlResource::Get()->InitAllHandlers() only when necessary
    wxsCodingLang m_AppLanguage;
    friend class wxWidgetsGUIConfigPanel;
    friend class wxWidgetsGUIAppAdoptingDlg;
};

#endif
